<template>
  <base-breadcrumb :breadcrumb="!isAudit">
    <div class="about-master-container">
      <a-card :bordered="false">
        <titleName title="科技管理计划详情" />
        <a-spin :spinning="loading">
          <a-form-model
            ref="ruleForm"
            :model="form"
          >
            <a-row>
                            <a-col span="8">
                              <a-form-model-item
                                label="项目名称"
                                prop="projectId"
                              >
                                <b-input
                                  v-model="form.viewName"
                                  disabled
                                />
                              </a-form-model-item>
                            </a-col>
<!--              <a-col span="8">-->
<!--                <a-form-model-item-->
<!--                  label="分公司"-->
<!--                  prop="branchCompanyId"-->
<!--                >-->
<!--                  <b-input-->
<!--                    v-model="form.branchCompany"-->
<!--                    disabled-->
<!--                  />-->
<!--                </a-form-model-item>-->
<!--              </a-col>-->
<!--              <a-col span="8">-->
<!--                <a-form-model-item-->
<!--                  label="项目名称"-->
<!--                  prop="projectId"-->
<!--                >-->
<!--                  <b-input-->
<!--                    v-model="form.projectName"-->
<!--                    disabled-->
<!--                  />-->
<!--                </a-form-model-item>-->
<!--              </a-col>-->
              <a-col span="8">
                <a-form-model-item
                  prop="planAchievementsName"
                  label="计划成果名称:"
                >
                  <BaseInput
                    v-model="form.planAchievementsName"
                    placeholder="请输入"
                    disabled
                  />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item
                  prop="achievementsTypeId"
                  label="成果分类:"
                >
                  <b-input
                    v-model="form.achievementsType"
                    disabled
                  />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item
                  prop="planAchievementsLevelId"
                  label="计划成果等级:"
                >
                  <b-input
                    v-model="form.planAchievementsLevel"
                    disabled
                  />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item
                  prop="planCompleteEmployeeId"
                  label="计划完成人"
                >
                  <a-tag v-if="form.planCompleteEmployee">{{ form.planCompleteEmployee }}</a-tag>
                  <span v-else style="opacity: 0;">无</span>
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item
                  prop="planCompleteDate"
                  label="计划完成日期:"
                >
                  <a-date-picker
                    v-model="form.planCompleteDate"
                    disabled
                    placeholder="请选择日期"
                    value-format="YYYY-MM-DD"
                  />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item
                  label="年度:"
                >
                  <b-input
                    v-model="form.year"
                    disabled
                  />
                </a-form-model-item>
              </a-col>
              <a-col span="24">
                <a-form-model-item
                  label="上传附件:"
                  prop="fileArrays"
                >
                  <file-link :canDownload="canDownload" :file-list="form.fileArrays" />
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-form-model>
        </a-spin>
        <div v-if="!isConsultation" class="page-btn-right-top">
          <a-button
            v-if="checkVisibleInDetail"
            type="primary"
            @click="handleActiveClose"
          >
            关闭
          </a-button>
        </div>
      </a-card>
    </div>
  </base-breadcrumb>
</template>
<script>
import { getPlan } from '@/api/science'
import Vue from 'vue'
import BaseEditPage from '@/views/baseEditPage'

export default {
  name: 'a' + Date.now(),
  extends: new BaseEditPage(),
  props: {
    // 是否作为审批详情
    isAudit: {
      type: Boolean,
      default: false
    },
    // 是否作为意见征询
    isConsultation: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      form: {
        viewName: ""
      },
      id: '',
      loading: false,
      column: 3,
      canDownload: true
    }
  },
  created() {
    this.id = this.$route.query.id
    this.getPlan()

    let btnPermissionList = this.$store.getters.btnPermission
    const index = btnPermissionList.findIndex(item => item.code === 'stm_004_dow_04')
    this.canDownload = index > 0
  },
  methods: {
    getPlan() {
      this.loading = true
      getPlan({ planId: this.id })
        .then((res) => {
          this.loading = false
          if (res.code === 200) {
            this.form = res.data
            this.form.viewName = this.form.branchCompany + "/" + this.form.projectName
          }
        })
        .catch((res) => {
          this.loading = false
        })
    }
  }
}
</script>
